package com.touch.client.forms;
import java.awt.event.*;
import javax.media.opengl.*;
import com.touch.client.databank.SpriteBank;
import com.touch.jgloo.owt.*;
public class MainMenuGLEvents implements GLEventListener, MouseListener
{
	protected JGLButton bLogin;
	protected JGLButton bCredits;	
	protected JGLButton bNewAccount;	
	protected JGLPane pMenu;		
	
	public void display(GLAutoDrawable drawable) 
	{
		pMenu.render();						
	}

	public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) 	{}
	public void init(GLAutoDrawable drawable) 
	{
		final GL gl = drawable.getGL();
		JGLButton.GL_INSTANCE = gl;		
						
		pMenu = new JGLPane(640, 480);
		bLogin = new JGLButton("Login", 120, 25);		
		bNewAccount = new JGLButton("New Account", 140, 25);
		bCredits = new JGLButton("Credits", 120, 25);
		
		pMenu.add(bLogin);
		pMenu.add(bCredits);
		pMenu.add(bNewAccount);		
		
		bLogin.setPosition(260, 200, 0);	
		bNewAccount.setPosition(260, 250, 0);
		bCredits.setPosition(260, 300, 0);
		pMenu.setBackground(MenuTextureDatabase.MAINMENU);	
		try 
		{
			SpriteBank.loadBank();
		}
		catch (Exception e) 
		{
			System.out.println("Error loading SpriteBank!");
			System.out.println("Confirm that the Sprites.xml file exists");
			e.printStackTrace();
			System.exit(-1);
		}
	}

	public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3,
			int arg4) {
		// TODO Auto-generated method stub
		
	}

	public void mouseClicked(MouseEvent e)
	{			
		pMenu.mouseClicked(e);		
		bLogin.mouseClicked(e);
		bNewAccount.mouseClicked(e);
		bCredits.mouseClicked(e);		
		if(bLogin.getIndex() == JGLComponent.getSelected())
			MainMenuControls.Login_Events.fLogin.setVisible(true);		
		else if(bNewAccount.getIndex() == JGLComponent.getSelected())
			MainMenuControls.New_Account_Events.fNewAccount.setVisible(true);				
	}
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	public void mouseExited(MouseEvent arg0) 	{}
	public void mousePressed(MouseEvent e) 	{	}
	public void mouseReleased(MouseEvent e)		{}
}
